﻿using System;

public partial class Guestbook : System.Web.UI.Page
{
   
   protected void submitButton_Click( object sender, EventArgs e )
   {
     
      using ( GuestbookEntities dbcontext = new GuestbookEntities() )
      {
        
         Message message = new Message(); 

         
         message.Date = DateTime.Now.ToShortDateString();
         message.Name = nameTextBox.Text;
         message.Email = emailTextBox.Text;
         message.Message1 = messageTextBox.Text;

         
         dbcontext.Messages.Add( message ); 
         dbcontext.SaveChanges(); 
      }

      
      nameTextBox.Text = String.Empty;
      emailTextBox.Text = String.Empty;
      messageTextBox.Text = String.Empty;

      
      messagesGridView.DataBind();
   } 

   
   protected void clearButton_Click( object sender, EventArgs e )
   {
      nameTextBox.Text = String.Empty;
      emailTextBox.Text = String.Empty;
      messageTextBox.Text = String.Empty;
   } 
} 

